﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HZ.Supervise.Model
{
    [Serializable]
    public class SuperviseQuery : IQuery
    {
        /// <summary>
        /// 额外自定义查询[格式: UserID = '1234' AND Name = 'Zeus2' AND ID NOT (SELECT ID FROM XX)]
        /// </summary>
        public string Append { get; set; }

        public string SortFields { get; set; }
        /// <summary>
        /// 采购目录编号
        /// </summary>
        public string ProcureCatalogID { get; set; }
        /// <summary>
        /// 流水号编号
        /// </summary>
        public string GoodsID { get; set; }
        /// <summary>
        /// 通用名
        /// </summary>
        public string ProductName { get; set; }
        /// <summary>
        /// 剂型
        /// </summary>
        public string MedicineModelName { get; set; }
        /// <summary>
        /// 规格型号
        /// </summary>
        public string Outlookc { get; set; }

		/// <summary>
		/// 包装规格
		/// </summary>
		public string PackOutlookc { get; set; }
        /// <summary>
        /// 生产企业
        /// </summary>
        public string CompanyName_SC { get; set; }
        public string CompanyName { get; set; }
        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { get; set; }
        /// <summary>
        /// 分类
        /// </summary>
        public string SortName { get; set; }
        /// <summary>
        /// 中标企业
        /// </summary>
        public string CompanyName_TB { get; set; }

        /// <summary>
        /// 型号
        /// </summary>
        public string Material { get; set; }

        /// <summary>
        /// 生产企业
        /// </summary>
        public string CompanyID_SC { get; set; }
        /// <summary>
        /// 分类编号
        /// </summary>
        public string SortID { get; set; }
        public string sid { get; set; }
        /// <summary>
        /// 商品名
        /// </summary>
        public string GoodsName { get; set; }

        /// <summary>
        /// 包装
        /// </summary>
        public string Pack { get; set; }
        /// <summary>
        /// 拼音码
        /// </summary>
        public string PinyinCode { get; set; }
        /// <summary>
        /// 五笔码
        /// </summary>
        public string WBCode { get; set; }
        /// <summary>
        /// 质量层次
        /// </summary>
        public string QualityLevel { get; set; }
        /// <summary>
        /// 医院编号
        /// </summary>
        public string HospitalID { get; set; }
        /// <summary>
        /// 地区编号
        /// </summary>
        public string AreaID { get; set; }
        /// <summary>
        /// 医院名称
        /// </summary>
        public string HospitalName { get; set; }
        /// <summary>
        /// 采购单名称
        /// </summary>
        public string OrderName { get; set; }

        /// <summary>
        /// 采购单编号
        /// </summary>
        public string OrderID { get; set; }

        /// <summary>
        /// 采购单开始时间
        /// </summary>
        public System.DateTime? StartTimeFrom { get; set; }
        /// <summary>
        /// 采购单开始时间
        /// </summary>
        public System.DateTime? StartTimeTo { get; set; }
        /// <summary>
        /// 采购单截止时间
        /// </summary>
        public System.DateTime? PlanEndTime { get; set; }

        /// <summary>
        /// 采购单提交时间 始
        /// </summary>
        public System.DateTime? PlanTimeFrom { get; set; }                                  //update by lhl on 2009-8-18

        /// <summary>
        /// 采购单提交时间 止
        /// </summary>
        public System.DateTime? PlanTimeTo { get; set; }
        /// <summary>
        /// 采购单中心提交时间
        /// </summary>
        public System.DateTime? CenSubmiitTime { get; set; }

        /// <summary>
        /// 采购单中心提交时间 始
        /// </summary>
        public System.DateTime? CenSubmiitTimeFrom { get; set; }                                  //update by lhl on 2009-8-18

        /// <summary>
        /// 采购单中心提交时间 止
        /// </summary>
        public System.DateTime? CenSubmiitTimeTo { get; set; }

        /// <summary>
        /// 采购单中心提交时间
        /// </summary>
        public System.DateTime? SubmiTime { get; set; }

        /// <summary>
        /// 采购单中心提交时间 始
        /// </summary>
        public System.DateTime? SubmiTimeFrom { get; set; }                                  //update by lhl on 2009-8-18

        /// <summary>
        /// 采购单中心提交时间 止
        /// </summary>
        public System.DateTime? SubmiTimeTo { get; set; }

        /// <summary>
        /// 配送企业编号
        /// </summary>
        public string CompanyID_PS { get; set; }
        /// <summary>
        /// 配送企业名称
        /// </summary>
        public string CompanyName_PS { get; set; }

        /// <summary>
        /// 注册证名称
        /// </summary>
        public string RegName { get; set; }
        public string RegCode { get; set; }
        /// <summary>
        /// 品牌
        /// </summary>
        public string Brand
        {
            set;
            get;
        }



        /// <summary>
        /// 投标企业编号
        /// </summary>
        public string CompanyID_TB { get; set; }
        /// <summary>
        /// 采购数量
        /// </summary>
        public int? PurchaseCountFrom { get; set; }
        /// <summary>
        /// 采购数量
        /// </summary>
        public int? PurchaseCountTo { get; set; }
        /// <summary>
        /// 采购单价
        /// </summary>
        public decimal? PriceFrom { get; set; }
        /// <summary>
        /// 采购单价
        /// </summary>
        public decimal? PriceTo { get; set; }
        /// <summary>
        /// 配送数量
        /// </summary>
        public int? DistributeCountFrom { get; set; }
        /// <summary>
        /// 配送数量
        /// </summary>
        public int? DistributeCountTo { get; set; }
        /// <summary>
        /// 入库数量
        /// </summary>
        public int? WarehouseCountFrom { get; set; }
        /// <summary>
        /// 入库数量
        /// </summary>
        public int? WarehouseCountTo { get; set; }
        /// <summary>
        /// 采购总金额
        /// </summary>
        public decimal? PurchaseAmountFrom { get; set; }
        /// <summary>
        /// 采购总金额
        /// </summary>
        public decimal? PurchaseAmountTo { get; set; }
        /// <summary>
        /// 入库总金额
        /// </summary>
        public decimal? WarehouseAmountFrom { get; set; }
        /// <summary>
        /// 入库总金额
        /// </summary>
        public decimal? WarehouseAmountTo { get; set; }

        /// <summary>
        /// 医保类型(甲类乙类民族药)
        /// </summary>
        public string InsuranceType { get; set; }
        /// <summary>
        /// 医院级别(三甲三乙二甲二乙等等)
        /// </summary>
        public string Levels { get; set; }

        /// <summary>
        /// 明细状态(统计缺货情况)
        /// </summary>
        public string OrderDetailState
        {
            get;
            set;
        }
        /// <summary>
        /// 是否有效目录
        /// </summary>
        public bool? IsUsing { get; set; }
        /// <summary>
        /// 是否贵重药品
        /// </summary>
        public bool? IsPrecious
        {
            get;
            set;
        }
        /// <summary>
        /// 药品来源
        /// </summary>
        public int? SortSource
        {
            get;
            set;
        }
        /// <summary>
        /// 转换系数
        /// </summary>
        public int? Factor { get; set; }
        /// <summary>
        /// 目标页面标题
        /// </summary>
        public string _Titile;
        /// <summary>
        /// 查询提示条件
        /// </summary>
        public string _QueryPrompt;
		/// <summary>
		/// 补贴Id
		/// </summary>
		public string SubsidyID
		{
			get;
			set;
		}

        /// <summary>
        /// 地区名称
        /// </summary>
        public string AreaName { get; set; }

        /// <summary>
        /// 企业类型，0生产2配送
        /// </summary>
        public int CompanyType
        {
            get;
            set;
        }
        /// <summary>
        /// 月份
        /// </summary>
        public string Mid { get; set; }

        /// <summary>
        /// 查询条件
        /// </summary>
        public string SqlStringWhere { get; set; }

        /// <summary>
        /// 基层，非基层
        /// </summary>
        public string IsCountry { get; set; }

        /// <summary>
        /// 是否政府办医疗机构
        /// 1政府办，0非政府办
        /// </summary>
        public string IsGovernment { get; set; }

        /// <summary>
        /// 区分中标目录
        /// 1国307,0省增补
        /// </summary>
        public string IsEssential { get; set; }
        /// <summary>
        /// 标识位
        /// </summary>
        public string Flag { get; set; }
        /// <summary>
        /// 预警消息编号
        /// </summary>
        public string MessageId { get; set; }
        /// <summary>
        /// 批号
        /// </summary>
        public string BatchRecordID { get; set; }

        /// <summary>
        /// 发票号
        /// </summary>
        public string InvoiceID { get; set; }

        /// <summary>
        /// 医院填报采购计划时间
        /// </summary>
        public DateTime? PurChaseTime { get; set; }

        /// <summary>
        /// 医院填报采购计划开始时间
        /// </summary>
        public DateTime? PurChaseTimeFrom { get; set; }
        /// <summary>
        /// 医院填报采购计划结束时间
        /// </summary>
        public DateTime? PurChaseTimeTo { get; set; }

        /// <summary>
        /// 是否国产  0：否   1：是
        /// </summary>
        public string IsGuoChan { get; set; }
        


        /// <summary>
        /// 上一页面
        /// </summary>
        public string BackPage { get; set; }

        public override string ToString()
        {
            // string where = string.Format("{0},{1},{2},{3}", HospitalID, CompanyID_PS, ProcureCatalogID, Append);

            string where = string.Empty;

            if (!string.IsNullOrEmpty(HospitalID))
            {
                where += "&HospitalID=" + HospitalID;
            }
            if (!string.IsNullOrEmpty(CompanyID_PS))
            {
                where += "&CompanyID_PS=" + CompanyID_PS;
            }

            if (!string.IsNullOrEmpty(ProcureCatalogID))
            {
                where += "&ProcureCatalogID=" + ProcureCatalogID;
            }

            if (!string.IsNullOrEmpty(Append))
            {
                where += "&Append=" + Append;
            }
            return where.Length > 0 ? "?" + where.Substring(1, where.Length) : "";
            //return base.ToString();
        }
        public static SuperviseQuery GetSuperviseQueryFromString(string s)
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            string[] ff = s.Split(new string[] { "&", "?" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var item in ff)
            {
                string[] split = item.Split('=');
                if (split.Length == 2)
                {
                    dic.Add(split[0], split[1]);
                }
            }
            SuperviseQuery result = new SuperviseQuery();
            if (dic.ContainsKey("HospitalID"))
            {
                result.HospitalID = dic["HospitalID"];
            }
            if (dic.ContainsKey("CompanyID_PS"))
            {
                result.HospitalID = dic["CompanyID_PS"];
            } if (dic.ContainsKey("ProcureCatalogID"))
            {
                result.HospitalID = dic["ProcureCatalogID"];
            } if (dic.ContainsKey("Append"))
            {
                result.HospitalID = dic["Append"];
            }
            return result;
        }

    }
}
